{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "57af450d",
   "metadata": {},
   "source": [
    "# 本周内容\n",
    "1. 人脸识别概念和基础\n",
    "2. 人脸识别应用\n",
    "3. 人脸识别实践-face++\n",
    "人脸检测\n",
    "人脸比对+人脸搜索\n",
    "人脸集合创建\n",
    "人脸\n",
    "人脸识别概念和基础"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "9cf3bd4e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "200\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'request_id': '1679496768,be84baf0-e132-4bf7-86dc-e8a3da2fabe3',\n",
       " 'time_used': 94,\n",
       " 'faces': [{'face_token': '07ec2ff04dde1272a2fa4861dba9b1c4',\n",
       "   'face_rectangle': {'top': 70, 'left': 85, 'width': 57, 'height': 57}}],\n",
       " 'image_id': '+3e1D5NUClRYsV6zLgOwyQ==',\n",
       " 'face_num': 1}"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# encoding:utf-8\n",
    "\n",
    "import requests\n",
    "import base64\n",
    "\n",
    "'''\n",
    "Face++ 人脸检测\n",
    "'''\n",
    "\n",
    "request_url = \"https://api-cn.faceplusplus.com/facepp/v3/detect\"\n",
    "# 二进制方式打开图片文件\n",
    "f = open('/Users/linyuqing/Desktop/u=3669276376,2213502260&fm=253&fmt=auto&app=138&f=JPEG 小.jpeg', 'rb')\n",
    "img = base64.b64encode(f.read())\n",
    "\n",
    "# 2. 酬载准备\n",
    "params = {\n",
    "    \"image_base64\":img,\n",
    "    \"api_key\":\"tS0itJdl-66gez8PZiXUiDaUKtO-ry6x\",\n",
    "    \"api_secret\":\"hcXnMxO-R-LANrwZdH2EJ6wGQ4_F4KHC\"\n",
    "}\n",
    "\n",
    "\n",
    "request_url = request_url\n",
    "headers = {'content-type': 'application/x-www-form-urlencoded'}\n",
    "response = requests.post(request_url, data = params, headers=headers)\n",
    "\n",
    "print(response.status_code)\n",
    "response.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5c61b999",
   "metadata": {},
   "outputs": [],
   "source": [
    "# https://console.faceplusplus.com.cn/app/apikey/list\n",
    "# https://console.faceplusplus.com.cn/documents/4888373"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
